package cn.uexpo.lhz.biz.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import cn.uexpo.lhz.biz.HallBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.HallMapper;
import cn.uexpo.lhz.domain.Hall;
import cn.uexpo.lhz.domain.HallExample;


@Transactional
@Service
public class HallBizImpl implements HallBiz {

	@Autowired
	private HallMapper hallMapper;
	@Override
	public int insert(Hall record) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.insert(record);
	}

	@Override
	public int insertSelective(Hall record) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(Hall record) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		// TODO Auto-generated method stub
		for (Integer id : ids) {
			hallMapper.deleteByPrimaryKey(id);
		}
		return 1;
	}

	@Override
	public int delete(List<Hall> records) throws BOException {
		// TODO Auto-generated method stub
		for (Hall record : records) {
			hallMapper.deleteByPrimaryKey(record.getId());
		}
		return 1;
	}

	@Override
	public int deleteByExample(HallExample example) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(Hall record) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(Hall record) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(Hall record, HallExample example) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.updateByExampleSelective(record,example);
	}

	@Override
	public int updateByExample(Hall record, HallExample example) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.updateByExample(record,example);
	}

	@Override
	public Hall selectByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.selectByPrimaryKey(id);
	}

	@Override
	public Hall selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
//		Hall item=null;
//		HallExample example=new HallExample();
//		HallExample.Criteria citeria=example.createCriteria();
//		 citeria.andExtstr3EqualTo(uniqueCode);
//		 List<Hall> items=hallMapper.selectByExample(example);
//		 if (items!=null&&items.size()>0) {
//			 item=items.get(0);
//		}
//		return item;
		return null;
	}

	@Override
	public List<Hall> selectByExample(HallExample example) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.selectByExample(example);
	}

	@Override
	public long countByExample(HallExample example) throws BOException {
		// TODO Auto-generated method stub
		return hallMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, HallExample example) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<Hall> records = (List<Hall>) hallMapper.selectByExample(example);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<Hall>(records));
	}




}
